<?php

class shipping_rates {

    private $arr_rate_object = array();
    private $err_msg = "";
    private $carrier_id;

    public function __construct($carrier_id) {
        $this->carrier_id = $carrier_id;
    }

    public function get_carrier_id() {
        return $this->carrier_id;
    }

    public function add_rate(shipping_rate_object $obj) {
        $this->arr_rate_object[$obj->id] = $obj;
    }

    public function set_error($msg) {
        $this->err_msg = $msg;
    }

    public function get_error() {
        return $this->err_msg;
    }

    public function is_error() {
        return strlen($this->err_msg) > 0 ? TRUE : FALSE;
    }

    public function clear_error() {
        $this->err_msg = "";
    }

    public function clear_rates() {
        $this->arr_rate_object = array();
    }

    public function get_rate($id) {

        if (isset($this->arr_rate_object[$id]))
            return $this->arr_rate_object[$id];
        else
            return NULL;
    }

    public function get_rates() {
        return $this->arr_rate_object;
    }

}

?>
